<?php

   $this->layout = false;
   $out = array('data' => array());
   $out["result"] = $result;
   if(!$result && isset($error))
   {
       $out['error'] = $error;
   }else if(isset($data))
   {
       $out['data'] = $data;
   }
   echo json_encode($out);
   Configure::write("debug",0);
?>